package com.bite.friend.Aspect;

import com.bite.friend.Service.ServiceImpl.UserServiceImpl;
import com.bite.friend.VO.UserVO;
import com.bite.redis.Interceptor.MyInterceptor;
import domain.MyThreadLocal;
import domain.R;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class UserStatusCheckAspect {

    @Autowired
    private UserServiceImpl userService;

    @Before(value = "@annotation(com.bite.friend.Aspect.CheckUserStatus)")
    public void checkUserStatus(){

        R<UserVO> personal = userService.personal();
        UserVO us = personal.getData();
        if (us == null){
            throw new RuntimeException("当前用户信息出现问题，请联系管理员");
        }
        if (us.getStatus() == 0){
            throw new RuntimeException("您已经被系统拉黑，请联系管理员");
        }

    }
}
